//
//  IncomeCell.m
//  JZRJAPPT
//
//  Created by mac on 16/5/8.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "IncomeCell.h"

@interface IncomeCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *numberLabel;

@property (weak, nonatomic) IBOutlet UILabel *novLabel;

@property (weak, nonatomic) IBOutlet UILabel *changeLabel;

@property (weak, nonatomic) IBOutlet UILabel *quantizationLabel;

@property (weak, nonatomic) IBOutlet UIView *ImageView;

@property (weak, nonatomic) IBOutlet UILabel *lastLabel;

@end

@implementation IncomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (void)setModel:(IncomeModel *)model{
    _model = model;
    _nameLabel.text = _model.Name;
    _numberLabel.text = _model.Code;
    
    _novLabel.text = [NSString stringWithFormat:@"%.2f%@", [model.IncomeRate floatValue] * 100,@"%"];
    //_novLabel.text = [_model.IncomeRate stringValue];
    //_changeLabel.text = [_model.WinRate stringValue];
    
     _changeLabel.text = [NSString stringWithFormat:@"%.2f%@", [_model.WinRate floatValue] * 100,@"%"];
    _quantizationLabel.text = [_model.FinalScore stringValue];
    NSString *str1 = [NSString stringWithFormat:@"%@",_model.LHOpinion];
    NSString *str2 = [str1 substringWithRange:NSMakeRange(0, 2)];
    NSLog(@"%@",str2);
    _lastLabel.text = str2;
    if ([_lastLabel.text isEqualToString:@"空仓"]) {
        _quantizationLabel.textColor = [UIColor cyanColor];
        UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"out"]];
        view.frame =CGRectMake(0, 2, 15, 15);
        [_ImageView addSubview:view];
        
    }if ([_lastLabel.text isEqualToString:@"持仓"]) {
        _quantizationLabel.textColor = [UIColor yellowColor];
        
        UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"in"]];
        view.frame =CGRectMake(0, 2, 15, 15);
        [_ImageView addSubview:view];

    }if ([_lastLabel.text isEqualToString:@"买入"]) {
        _quantizationLabel.textColor = [UIColor redColor];
        UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"buy"]];
        view.frame =CGRectMake(0, 2, 15, 15);
        [_ImageView addSubview:view];
    }if ([_lastLabel.text isEqualToString:@"卖出"]) {
        _quantizationLabel.textColor = [UIColor greenColor];
        UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sold"]];
        view.frame =CGRectMake(0, 2, 15, 15);
        [_ImageView addSubview:view];
    }

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
